package com.gopay.scheduler.job;

import java.util.List;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.gopay.common.domain.cbrmb.customs.CbRmbCustomsPayment;
import com.gopay.scheduler.GopayBaseJob;
import com.gopay.scheduler.service.cbrmb.CbRmbCustomsPaymentService;

/**
 * 跨境人民币海关报关超时失效清理Job
 * 
 * @CbRmbCustomsPaymentTimeOutCleanJob.java
 * @Description: 跨境人民币，海关报关系统，每小时扫描创建时间距当前4天以上的报关进行中数据，将其状态置为报关失败
 * @author lailingyu
 * @2017-02-21  上午9:53:30 www.gopay.com.cn Inc.All rights reserved.
 */
public class CbRmbCustomsPaymentTimeOutCleanJob extends GopayBaseJob {
    private Logger logger = LoggerFactory.getLogger(this.getClass());

    @Resource(name = "cbRmbCustomsPaymentService")
    private CbRmbCustomsPaymentService cbRmbCustomsPaymentService;

    @Override
    protected void doJobInternal() {
        logger.info("=====跨境人民币海关报关超时失效清理定时任务开始=====");
        List<CbRmbCustomsPayment> timeOutList = cbRmbCustomsPaymentService.getTimeOutOrder();
        if (timeOutList != null && timeOutList.size() > 0) {
            for (CbRmbCustomsPayment cbRmbCustomsPayment : timeOutList) {
                cbRmbCustomsPayment.setState("04");
                cbRmbCustomsPaymentService.updateOrder(cbRmbCustomsPayment);
            }
        }

        logger.info("=====跨境人民币海关报关超时失效清理定时任务结束，共清理" + timeOutList.size() + "条数据=====");
    }
}
